<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<script src="https://www.w3school.com.cn/jquery/jquery-1.11.1.min.js"></script>
	<body>
		<div class="title">添加附件：</div>
		<input type="file" class="accessories" id="accessories" onchange="fileUp()" multiple="multiple">
		<div class="filesList" id="files"></div>
		<input type="button" onclick="upload()" value="上传" />
	</body>
	<script>
		//上传附件兼容性IE9及以上,chrome,firefox等
		var receiveArray = [],
		    temp = [],
		    str;
		var files = [];
		function fileUp() {
		    var fileTemp = $("#accessories").prop("files")
			for(var i=0;i<fileTemp.length;i++){
				files.push(fileTemp[i])	
				$("#files").append("<div>"+fileTemp[i].name+"</div>")
			}
		}
		function upload(){
			var fd = new FormData();
			for(var i in files){
				fd.append("files", files[i]);
			}
			var xhr = new XMLHttpRequest();
			xhr.open("POST", "upload.do"); //修改成自己的接口
			xhr.send(fd);
		}
	</script>
</html>
